package com.bank.backend.controller;

import com.bank.backend.annotation.AuthCheck;
import com.bank.backend.model.dto.TradeQueryDTO;
import com.bank.backend.result.Result;
import com.bank.backend.service.TradeService;
import com.bank.backend.result.PageResult;
import com.bank.backend.model.vo.TradeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 交易记录管理接口
 */
@RestController
@RequestMapping("/admin/transactions")
@Api(tags = "交易管理")
@Slf4j
public class TradeManageController {

    @Resource
    private TradeService tradeService;

    /**
     * 查询交易记录
     */
    @GetMapping
    @ApiOperation("查询交易记录")
    @AuthCheck(mustRole = "管理员")
    public Result<PageResult<TradeVO>> queryTradeList(TradeQueryDTO queryDTO) {
        PageResult<TradeVO> result = tradeService.queryTradeList(queryDTO);
        return Result.success(result);
    }

    @DeleteMapping
    @ApiOperation("删除交易记录")
    @AuthCheck(mustRole = "管理员")
    public Result deleteTrade(@RequestParam(value = "trade_id") Integer tradeId) {
        tradeService.deleteTrade(tradeId);
        return Result.success(null, "删除交易记录成功");
    }
} 